package Chapter2.Comparing.c8;

import java.io.File;

public class Recursion {
    public static void main(String[] args) {
        //System.out.println(recursionSum(5));

        File file = new File("E:\\users");
        System.out.println();
        displayFiles(file);
    }

    /*public static int recursionSum (int a){
        if (a>1) {
            return recursionSum(a -1)+ recursionSum( a -2);
        }
        else {
            return 2;
        }
    }*/

    public static void displayFiles(File file ) {

        //File[] files = file.listFiles();
        //if(file==null){
        //    System.out.println("文件夹为空！！！！");
            //File[] files = file.listFiles();
            //System.out.println("Directory: " + file.getName());

                /*for (File file1 : files) {
                    if (file1.isDirectory()) {
                        System.out.println("包: " + file1.getName());
                        displayFiles(file1);

                    } else {
                        //System.out.println();
                        System.out.println("*----------文件: " + file1.getName());
                    }
                }*/


        //else {
            File[] files = file.listFiles();
            if(files==null){
                System.out.println("文件夹为空！！！！");
            }
            for (File file1 : files) {
                if (file1.isDirectory()) {

                    System.out.println("包: " + file1.getName());
                    displayFiles(file1);

                } else {
                    //System.out.println();
                    System.out.println("*----------文件: " + file1.getName());
                }
            }
            //System.out.println();
            //System.out.println("**----------文件: " + file.getName());
        //}
    }

}
